package com.tanhua.server.service;

import com.tanhua.dubbo.api.mongo.UserLocationApi;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class BaiduService {

    @DubboReference
    private UserLocationApi userLocationApi;

    /**
     * 上报地理位置
     * @param paramMap
     */
    public void reportLocation(Map<String, Object> paramMap) {
        //1.取出参数
        // 纬度
        Double y = (Double) paramMap.get("latitude");
        // 经度
        Double x = (Double) paramMap.get("longitude");
        // 所在位置描述
        String addrStr = (String)paramMap.get("addrStr");
        //2.调用api保存
        userLocationApi.save(UserHolder.getUserId(),x,y,addrStr);
    }
}
